<template>
	<view class="main">
		<!-- <view class="box">
			<button class="tui-btn tui-btn-block tui-green tui-fillet" hover-class="tui-green-hover" @click="outLoginBtn('2')">
				<tui-icon name="explain-fill" color="#fac240"></tui-icon>
				<text class="ml24">求助</text>
			</button>
			<button class="tui-btn tui-btn-block tui-green tui-fillet" hover-class="tui-green-hover" @click="outLoginBtn('1')">
				<tui-icon name="like-fill" color="#fac240"></tui-icon>
				<text class="ml24">匹配</text>
			</button>
		</view> -->
		<view style="width: 100%;">
			<view class="title"><image src="https://jihe2.oss-cn-beijing.aliyuncs.com/xinli/NO.png" mode=""></image></view>
			<view class="logo" @click="outLoginBtn('2')">
				<image src="https://jihe2.oss-cn-beijing.aliyuncs.com/xinli/login/logo.png" mode=""></image>
			</view>
			<view class="sub-title" v-if="type == 1">一键求助</view>
			<view class="sub-title" v-if="type >= 2">一键反馈</view>
			<view class="tui-flex">
				<view class="tui-center tui-col-4" @click="goZhiyuanzhe">
					<view class="sub-icon"><image src="https://jihe2.oss-cn-beijing.aliyuncs.com/xinli/icon.png"></view>
					<view class="sub-tag">找志愿者</view>
				</view>
				<view class="tui-center tui-col-4" @click="outLoginBtn('1')" v-if="type == 1">
					<view class="sub-icon"><image src="https://jihe2.oss-cn-beijing.aliyuncs.com/xinli/icon.png"></image></view>
					<view class="sub-tag">恐友匹配</view>
				</view>
				<!-- <view class="tui-center tui-col-4" @click="detail('1')">
					<view class="sub-icon"><image src="https://jihe2.oss-cn-beijing.aliyuncs.com/xinli/icon.png></image></view>
					<view class="sub-tag">模拟自测</view>
				</view> -->
				 <view class="tui-center tui-col-4" @click="jiuxu" v-else>
					<view class="sub-icon"><image src="https://jihe2.oss-cn-beijing.aliyuncs.com/xinli/icon.png"></image></view>
					<view class="sub-tag">专家就绪</view>
				</view><!-- -->
			</view>
		</view>
	</view>
</template>

<script>
	import tuiIcon from "@/components/icon/icon"
	export default {
		data() {
			return {
				userInfo : {},
				type : 0
			}
		},
		components: {
			tuiIcon
		},
		computed:{
		},
		onShow() {
			let userInfo = uni.getStorageSync('userInfo');
			this.type = userInfo.type;
			if( !userInfo || '' == JSON.stringify(userInfo) || '{}' == JSON.stringify(userInfo)){
				uni.reLaunch({
					url: '/pages/login/login'
				}) 
			}else{
				let promise = this.tim.login({
					userID: userInfo.userId,
					userSig: userInfo.userSig
				});
				promise.then((res) => {
					//登录成功后 更新登录状态
					this.$store.commit("toggleIsLogin", true);
					//自己平台的用户基础信息
					//tim 返回的用户信息
					uni.setStorageSync('userTIMInfo', res.data)
				}).catch((err) => {
					console.warn('login error:', err); // 登录失败的相关信息
				});
			}
		},
		onLoad() {
			// #ifndef H5
			uni.showShareMenu({
				showShareItems : ['qq', 'qzone', 'wechatFriends', 'wechatMoment']	
			});
			// #endif
		},
		methods: {
			
			goZhiyuanzhe(){
				uni.navigateTo({
					url: '/pages/tim/friends?show=1dsa'
				})
			},
			onNavigationBarButtonTap(e) {
				// 分享
				if (e.float == "right") {
					uni.showToast({
						title: this.$tools.commons.getConfig('fenxiangTitle'),
						icon: "none"
					})
					this.$tools.share.shareUrl();
				}
			},
			jiuxu: function() {
				let userInfo = uni.getStorageSync('userInfo');
				console.log(userInfo); 
				if( userInfo.type > 2 ){
					this.$tools.commons.setPage({isActive : 0});
					uni.reLaunch({
						url: '/pages/tim/record'
					})             
					
					this.$apiW.updateUserStuts({ userId : userInfo.userId , stuts : 1});
				}else{
					uni.showToast({
						title: '您不是专家~',
						icon: "none"
					})
				}
			},
			detail: function() {
				uni.showToast({
					title: '详情功能尚未完善~',
					icon: "none"
				})
			},
            outLoginBtn(type){
                this.$tools.commons.help(type);
            }
		}
	}
</script>

<style scoped lang="scss">
	@import '../../static/style/thorui.css';
	uni-page-body{
		height: 100%;
	}
	.main{
		height: 100%;
		background-image: url(//jihe2.oss-cn-beijing.aliyuncs.com/xinli/bg.jpg);
		justify-content: center;
		display: flex;
		align-items: center;
	}
	.title{
		width: 500upx;
		height: 178upx;
		margin: 0 auto;
	}
	uni-image{
		width: 100%;
		height: 100%;
	}
	.logo{
		width: 400upx;
		height: 377upx;
		margin: 0 auto;
	}
	.sub-title{
		text-align: center;
		font-size: 40upx;
		color: #df5451;
		font-weight: bolder;
		line-height: 2;
	}
	.sub-icon{
		width: 100upx;
		height: 100upx;
		margin: auto;
	}
	.sub-tag{
		font-size: 34upx;
		color: #df5451;
		font-weight: bolder;
		line-height: 2;
	}
	.tui-flex{
		margin-top: 100upx;
	}
</style>
